﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Muel.TypeScriptFacade.Core.Configuration
{
    public enum ValidationErrorType
    {
        InvalidCharactersInFacadeName,
        UnexpectedAutoSnapshot,
        InvalidCharactersInSnapshotName,
        InvalidCharactersInHasChangesName,
        SnapshotNameEqualsHasChangesName,
        FacadeNameIsReserved,
        SnapshotMethodNameIsReserved,
        HasChangesMethodNameIsReserved,
        RevertMethodNameIsReserved,
    }

    public class ValidationError
    {
        internal static string GetMessage(ValidationErrorType type) {
            switch (type)
            {
                case ValidationErrorType.InvalidCharactersInFacadeName:
                    return Strings.SettingsValidationErrorInvalidFacadeName;
                    
                case ValidationErrorType.UnexpectedAutoSnapshot:
                    return Strings.SettingsValidationErrorUnexpectedAutoSnapshot;
                    
                case ValidationErrorType.InvalidCharactersInSnapshotName:
                    return Strings.SettingsValidationErrorInvalidSnapshotName;
                    
                case ValidationErrorType.InvalidCharactersInHasChangesName:
                    return Strings.SettingsValidationErrorInvalidHasChangesName;

                case ValidationErrorType.SnapshotNameEqualsHasChangesName:
                    return Strings.SettingsValidationErrorSnapshotNameEqualsHasChangesName;

                case ValidationErrorType.FacadeNameIsReserved:
                    return Strings.SettingsValidationErrorFacadeNameIsReserved;

                case ValidationErrorType.SnapshotMethodNameIsReserved:
                    return Strings.SettingsValidationErrorSnapshotMethodNameIsReserved;

                case ValidationErrorType.HasChangesMethodNameIsReserved:
                    return Strings.SettingsValidationErrorHasChangesMethodNameIsReserved;

                case ValidationErrorType.RevertMethodNameIsReserved:
                    return Strings.SettingsValidationErrorRevertMethodNameIsReserved;

                default:
                    return string.Empty;
            }
        }

        private ValidationErrorType errorType;
        public ValidationError(ValidationErrorType type)
        {
            this.errorType = type;
        }
        public ValidationErrorType ErrorType { get { return errorType; } }
        public string ErrorMessage
        {
            get
            {
                return string.Format("{0}: {1}",
                    this.ErrorType.ToString(),
                    GetMessage(this.ErrorType));
            }
        }

    }

}
